define(function(require, exports, module) {

	function onload(api) {
		return {
			name: 'OrgSelector',
			components: {
				CascadeSelector : require("../CascadeSelector/Widget.js").onload(api)
			},
			props: {
				labelWidth: {
					type: String,
					default: '120px',
					required: false
				},
				value: {
					type: Array,
					required: true
				},
				width: {
					type: String,
					default: '100%',
					required: false
				},
				// 每行几列
				colCountOfRow: {
					type: Number,
					default: 2,
					required: false
				},
				// 级别
				level: {
					type: Number,
					default: 5,
					required: false
				}
			},
			data() {
				return {
					showOrg: showOrg,
					currentValue: this.value,
					selectors: [{
							label: '省厅',
							options: [],
							optionsSource: api.listDept,
							detailSource: api.getDept,
							optionsSourceResultKey: 'data',
							optionParams: {
								ancestors: '0'
							},
							optionParamsValueKey: 'parentId',
							optionLabelKey: 'deptName',
							optionValueKey: 'deptId'
						},
						{
							label: '市局',
							options: [],
							optionsSource: api.listDept,
							detailSource: api.getDept,
							optionsSourceResultKey: 'data',
							optionParams: {},
							optionParamsValueKey: 'parentId',
							optionLabelKey: 'deptName',
							optionValueKey: 'deptId'
						},
						{
							label: '县/区分局',
							options: [],
							optionsSource: api.listDept,
							detailSource: api.getDept,
							optionsSourceResultKey: 'data',
							optionParams: {},
							optionParamsValueKey: 'parentId',
							optionLabelKey: 'deptName',
							optionValueKey: 'deptId'
						},
						{
							label: '派出所',
							options: [],
							optionsSource: api.listDept,
							detailSource: api.getDept,
							optionsSourceResultKey: 'data',
							optionParams: {},
							optionParamsValueKey: 'parentId',
							optionLabelKey: 'deptName',
							optionValueKey: 'deptId'
						},
						{
							label: '警务区',
							options: [],
							optionsSource: api.listDept,
							detailSource: api.getDept,
							optionsSourceResultKey: 'data',
							optionParams: {},
							optionParamsValueKey: 'parentId',
							optionLabelKey: 'deptName',
							optionValueKey: 'deptId'
						},
						{
							label: '社区/村',
							options: [],
							optionsSource: api.listCommunity,
							detailSource: api.getCommunityByAreaId,
							optionsSourceResultKey: 'rows',
							optionParams: {},
							optionParamsValueKey: 'policeArea',
							optionLabelKey: 'areaCommunityName',
							optionValueKey: 'areaId'
						},
						{
							label: '小区/屯',
							options: [],
							optionsSource: api.listOrganization,
							detailSource: api.getOrganization,
							optionsSourceResultKey: 'data',
							optionParams: {
								addressType: '6'
							},
							optionParamsValueKey: 'pid',
							optionLabelKey: 'addressName',
							optionValueKey: 'id'
						},
						{
							label: '楼栋',
							options: [],
							optionsSource: api.listBuilding,
							detailSource: api.getBuilding,
							optionsSourceResultKey: 'rows',
							optionParams: {
								pageNum: 1,
								pageSize: 1000
							},
							optionParamsValueKey: 'community',
							optionLabelKey: 'name',
							optionValueKey: 'id'
						},
						{
							label: '房屋',
							options: [],
							optionsSource: api.listHouse,
							detailSource: api.getHouse,
							optionsSourceResultKey: 'rows',
							optionParams: {
								pageNum: 1,
								pageSize: 1000
							},
							optionParamsValueKey: 'buildingId',
							optionLabelKey: 'houseNumber',
							optionValueKey: 'id'
						}
					]
				}
			},
			created() {},
			methods: {
				resetSelectors(newValue) {
					this.currentValue = newValue
					this.$refs.cascadeSelector.resetSelectors(newValue)
				},
				// 获得当前选中的标签数组
				getSelectedLabels() {
					return this.$refs.cascadeSelector.getSelectedLabels()
				}
			}
		}
	}

	module.exports = {
		onload
	};
});
